home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / bbs_soft / mrun210.zip / MRUN210B.WAS < prev    next >
Text File  |  1993-04-28  |  10KB  |  390 lines

  1. ;MailRun v2.10:  Part B, changesettings
  2. ;1992-1993 Gerald P. Sully, all rights reserved.
  3.  
  4. #comment
  5. **************************************************************************
  6. **************************************************************************
  7. * This file contains routines related to changing MailRun
  8. * settings.  It puts up the MailRun Settings dialog box, and
  9. * writes any changes to the *.MRN file.  If the user changes
  10. * the MailRun directory, it will move all MailRun Files to the
  11. * new directory and stop the script.
  12. **************************************************************************
  13. **************************************************************************
  14. #endcomment
  15.  
  16. #define MRUN210B
  17. #define MRUN210BC
  18. #define MRUN210AB
  19.  
  20. #include "mrun210.h"
  21.  
  22. #comment
  23. *********************************************************************
  24. * MAIN()
  25. * Calls checkchild(), checkdir(), settingsbox(),
  26. * loadsettings(), changemailrun(), makemailrunlist(),
  27. * menudim(), newmailrun(), interfaceon(), changemrundir(),
  28. * writesettings(), findstring(), checkchanged(),
  29. * Allows the user to change the settings in the [MailRun]
  30. * section of the *.MRN file.
  31. *********************************************************************
  32. #endcomment
  33.  
  34. proc main
  35. string LastMRunDir, LastMailDir, LastReplyDir
  36. string LastDLDir, LastULDir, LastMRun
  37. integer dialogstatus
  38.     menudim()
  39.     checkchild()
  40.     LastMRun = MailRun
  41.     loadsettings()
  42.     LastMailDir = MailDir
  43.     LastReplyDir = ReplyDir
  44.     LastDLDir = DownloadDir
  45.     LastULDir = UploadDir
  46.     if FLAGS & DEFAULTS
  47.         MailRunList = "mailrun.ini"
  48.         MailRunTrunc = "mailrun.ini"
  49.         LastMRunDir = MailRunDir
  50.     else
  51.         findfirst MailRun
  52.         MailRunTrunc = $FILENAME
  53.         makemailrunlist()
  54.     endif
  55.     FLAGS &= UNCHANGED
  56.     settingsbox()
  57.     if !(FLAGS & DEFAULTS)
  58.         disable CTRL 242
  59.     endif
  60.     if LogRun == 0
  61.         disable CTRL 71
  62.         disable CTRL 72
  63.     endif
  64.     if FLAGS & RUNNING
  65.         disable CTRL 170
  66.     endif
  67.     if FLAGS & NEW
  68.         newmailrun()
  69.         getfirstitem()
  70.         LastMRun = MailRun
  71.     endif
  72.     interfaceon()
  73.     while 1
  74.         dialogstatus = $DIALOG
  75.         switch dialogstatus
  76.             case 10
  77.                 ;User selected "Save"
  78.                 ;if the directories chosen in settingsbox()
  79.                 ;don't exist, create them
  80.                 if checkdir(&MailRunDir, LastMRunDir) && \
  81.                     checkdir(&MailDir, LastMailDir) && \
  82.                     checkdir(&ReplyDir, LastReplyDir) && \
  83.                     checkdir(&DownloadDir, LastDLDir) && \
  84.                     checkdir(&UploadDir, LastULDir)
  85.                     ;if all directories were successfully created...
  86.                     chdir MailRunDir
  87.                     writesettings()
  88.                 else
  89.                     updatedlg 128
  90.                 endif
  91.                 FLAGS &= UNCHANGED
  92.             endcase
  93.             case 11
  94.                 ;User selected "Done"
  95.                 if checkchanged()
  96.                     ;if user has no unsaved changes...
  97.                     if (FLAGS & DEFAULTS) && !(findstring(LastMRunDir, MailRunDir))
  98.                         ;if user has changed the MailRun Directory    
  99.                         changemrundir(LastMRunDir)
  100.                         updatedlg 128
  101.                     else
  102.                         exit
  103.                     endif
  104.                 endif
  105.             endcase
  106.             case 70
  107.                 ;User selected the Log MailRun checkbox
  108.                 if LogRun == 0
  109.                     ;If logging was turned off, disable the other checkboxes
  110.                     disable CTRL 71
  111.                     disable CTRL 72
  112.                 else
  113.                     ;Otherwise, enable the checkboxes
  114.                     enable CTRL 71
  115.                     enable CTRL 72
  116.                 endif
  117.                 FLAGS |= CHANGED
  118.                 updatedlg 1
  119.             endcase
  120.             case 170
  121.                 ;User changed mailrun with combobox
  122.                 if checkchanged()
  123.                     changemailrun()
  124.                     getfirstitem()
  125.                     LastMRun = MailRun
  126.                     updatedlg -1
  127.                 else
  128.                     findfirst MailRun
  129.                     MailRunTrunc = $FILENAME
  130.                     updatedlg 512
  131.                 endif
  132.             endcase
  133.             case 230
  134.             case 231
  135.             case 232
  136.             case 233
  137.             case 234
  138.             case 235
  139.             case 236
  140.             case 237
  141.             case 238
  142.             case 239
  143.             case 240
  144.             case 241
  145.             case 242
  146.             case 71
  147.             case 72
  148.             case 73
  149.                 FLAGS |= CHANGED
  150.             endcase
  151.         endswitch
  152.     endwhile
  153. endproc
  154.  
  155.  
  156. #comment
  157. *********************************************************************
  158. * CHECKDIR()
  159. * Called by main()
  160. * Creates a directory.  If the directory already exists or
  161. * was successfully created, a value of 0 is returned.  If
  162. * an error occurs, the name of NewDir is changed to that
  163. * of OldDir, and a value of 1 is returned.
  164. *********************************************************************
  165. #endcomment
  166.  
  167. func checkdir : integer
  168. strparm NewDir, OldDir
  169.     chdir NewDir
  170.     if FAILURE
  171.         mkdir NewDir
  172.         if FAILURE
  173.             usermsg "Unable to create directory %s" NewDir
  174.             NewDir = OldDir
  175.             return 0
  176.         endif
  177.     endif
  178.     return 1
  179. endfunc
  180.  
  181.  
  182. #comment
  183. *********************************************************************
  184. * NEWMAILRUN()
  185. * Called by main()
  186. * Calls fverify(), filesave(), makemrn(), makemailrunlist(),
  187. * makefullname()
  188. * Prompts the user for the name of a new *.MRN file, checks
  189. * the name, and calls routines to create it.
  190. *********************************************************************
  191. #endcomment
  192.  
  193. proc newmailrun
  194. string NewRun, temp
  195.     ;Make sure the entered MailRun ID is the correct length
  196.     ;and that it doesn't already exist
  197.     while 1
  198.         NewRun = ""
  199.         sdlginput "New MailRun" \
  200.             "Enter the ID of the new mailrun:" NewRun
  201.         if FAILURE
  202.             exit
  203.         endif
  204.         strlwr NewRun
  205.         if not fverify(NewRun)
  206.             usermsg \
  207.             "A mailrun ID must be a valid DOS file name without the extension."
  208.             loopwhile
  209.         endif
  210.         strfmt temp "%s.mrn" NewRun
  211.         NewRun = makefullname(MailRunDir, temp)
  212.         if isfile NewRun
  213.             errormsg "That MailRun already exists!"
  214.         else
  215.             exitwhile
  216.         endif
  217.     endwhile
  218.  
  219.     ;Update the previous mailrun
  220.     filesave()
  221.     delfile MailRun
  222.     ;Create the new mailrun
  223.     MailRunTrunc = temp
  224.     makemrn()
  225.     makemailrunlist()
  226.     updatedlg -1
  227. endproc
  228.  
  229.  
  230. #comment
  231. *********************************************************************
  232. * CHANGEMRUNDIR()
  233. * Called by main()
  234. * Calls movefiles(), fileexit(), makefullname()
  235. * Requests confirmation, moves all MailRun support files
  236. * to the new MailRun Directory, and shuts down so that the
  237. * user can restart.
  238. *********************************************************************
  239. #endcomment
  240.  
  241. proc changemrundir
  242. strparm LastMRunDir
  243. string WarnMsg, CleanupFile
  244. integer Response
  245.     strfmt WarnMsg "All MailRun files will be moved to`r`n`r`n\
  246.       %s`r`n`r`nand MailRun will have to be restarted.`r`n`r`nDo you wish \
  247. continue?" MailRunDir
  248.     sdlgmsgbox "MailRun Message" WarnMsg QUESTION YESNO Response 2
  249.     switch Response
  250.         case 6
  251.             ;User selected "Yes"
  252.             cleanupfile = makefullname(TempDir, "CLEANUP.TMP")
  253.             profilerd cleanupfile "cleanup" "LastMRun" MailRun
  254.             findfirst MailRun
  255.             MailRunTrunc = $FILENAME
  256.             profilewr MailRunIni "MailRun" "MailRunDir" MailRunDir
  257.             movefiles(LastMRunDir, MailRunDir, "MRUN210?.WA?")
  258.             movefiles(LastMRunDir, MailRunDir, "MRUN210.H")
  259.             movefiles(LastMRunDir, MailRunDir, "NEWFILES.WA?")
  260.             movefiles(LastMRunDir, MailRunDir, "TERMINAL.WA?")
  261.             movefiles(LastMRunDir, MailRunDir, "*.MRN")
  262.             movefiles(LastMRunDir, MailRunDir, "*.?DX")
  263.             movefiles(LastMRunDir, MailRunDir, "*.?BF")
  264.             movefiles(LastMRunDir, MailRunDir, "MRUNICON.DLL")
  265.             movefiles(LastMRunDir, MailRunDir, "MAILRUN.WRI")
  266.             fileexit()
  267.         endcase
  268.         case 7
  269.             ;User selected "No"
  270.             MailRunDir = LastMRunDir
  271.         endcase
  272.     endswitch
  273. endproc    
  274.  
  275.  
  276. #comment
  277. *********************************************************************
  278. * MOVEFILES()
  279. * Called by changemrundir()
  280. * Calls makefullname()
  281. * Moves files matching the given filespec from their current
  282. * location to the MailRun directory.
  283. *********************************************************************
  284. #endcomment
  285.  
  286. proc movefiles
  287. strparm OldDir, NewDir, Spec
  288. string OldFile, NewFile, OldSpec
  289.     OldSpec = makefullname(OldDir, Spec)
  290.     findfirst OldSpec
  291.     while FOUND
  292.         if not strcmpi $FILENAME "MRUN210.WAS"
  293.             if not strcmpi $FILENAME "MRUN210.WAX"
  294.                statmsg "Moving %s" $FILENAME
  295.                 OldFile = makefullname(OldDir, $FILENAME)
  296.                 NewFile = makefullname(NewDir, $FILENAME)
  297.                 copyfile OldFile NewFile
  298.                 delfile OldFile
  299.             endif
  300.         endif
  301.         findnext
  302.     endwhile
  303. endproc
  304.  
  305.  
  306. #comment
  307. *********************************************************************
  308. * SETTINGSBOX()
  309. * Called by main()
  310. * Displays the MailRun Settings dialog box.
  311. *********************************************************************
  312. #endcomment
  313.  
  314. proc settingsbox
  315. destroydlg
  316. HelpPage = 4
  317. dialogbox 15 36 340 222 15 "MailRun Settings" HELPID HelpPage
  318.    groupbox 10 28 200 96 "Directories" shadow
  319.    text  16 42 71 8 right "MailRun Directory:"
  320.    text  16 58 71 8 right "Mail Directory:"
  321.    text  16 74 71 8 right "Reply Directory:"
  322.    text  16 90 71 8 right "Download Directory:"
  323.    text  16 106 71 8 right "Upload Directory:"
  324.    editbox 91 56 110 12 MailDir
  325.    editbox 91 72 110 12 ReplyDir
  326.    editbox 91 88 110 12 DownloadDir
  327.    editbox 91 104 110 12 UploadDir
  328.    groupbox 224 28 102 96 "Parameters" shadow
  329.    text  234 42 62 8 right "Dial Attempts:"
  330.    text  234 58 62 8 right "Dial Timeout:"
  331.    text  234 74 62 8 right "Dial Pause:"
  332.    text  234 90 62 8 right "Idle Timeout:"
  333.    text  234 106 62 8 right "Packets to Save:"
  334.    editbox 300 40 16 12 DialAttempts
  335.    editbox 300 56 16 12 DialTimeout
  336.    editbox 300 72 16 12 DialPause
  337.    editbox 300 88 16 12 IdleTime
  338.    editbox 300 104 16 12 SavePackets
  339.    groupbox 10 132 124 59 "Logging" shadow
  340.    checkbox 18 144 112 12 "Capture mailrun to log file" LogRun
  341.    checkbox 18 158 112 12 "Append to existing log file" AppendLog
  342.    checkbox 18 172 112 12 "Capture ANSI codes in log file" AnsiInLog
  343.    checkbox 18 200 134 12 "Filter duplicates from d/l database" NewfileFilter
  344.    groupbox 144 132 184 59 "Utilities" shadow
  345.    text  145 146 65 8 right "Archive Utility:"
  346.    text  145 160 65 8 right "QWK Mail Reader:"
  347.    text  145 174 65 8 right "Log File Viewer:"
  348.    editbox 214 144 107 12 Archiver
  349.    editbox 214 158 107 12 QWKReader
  350.    editbox 214 172 107 12 LogViewer
  351.    pushbutton 191 200 40 14 "&Save" normal default
  352.    pushbutton 252 200 40 14 "&Done" normal
  353.    text  100 11 52 8 right "Settings for:"
  354.    combobox 156 9 72 42 MailRunList MailRunTrunc sort
  355.    editbox 91 40 110 12 MailRunDir
  356. enddialog
  357. endproc
  358.  
  359.  
  360.  
  361.